<?php
//模型
class PrivgroupModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'priv_group';
		$this->catchs = array();
	}
	
	function get_list($arr,$page=1,$size=10){
		$where = ' 1 ';
		
		
		if(isset($arr['keyword']) && !empty($arr['keyword'])){
			$where .= " AND (info LIKE '%{$arr['keyword']}%' OR name LIKE '%{$arr['keyword']}%')";
		}
		if(isset($arr['is_enable'])){
			$where .= " AND is_enable='{$arr['is_enable']}'";
		}
		
		
		$res = $this->_where_get_list($where,$page,$size);
		return $res;
	}
	
	function get_info($id){
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where id='{$id}' limit 1";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
	
	function ids_get_data($ids){
		if(is_array($ids)){
			$ids = implode(',',$ids);
		}
		if(empty($ids)){
			return false;
		}
		if(isset($this->catchs[$ids])){
			return $this->catchs[$ids];
		}
		
		$sql  = "select name,ids from ".$this->db->dbprefix.$this->table." where id in({$ids}) limit 100";
		$query = $this->db->query($sql);
		$res = $query->result_array();
		
		$this->catchs[$ids] = $res;
		return $res;
		
	}
	
}

